<?php

namespace StandAlone;

use GuzzleHttp\Exception\GuzzleException;
use PHPUnit\Framework\TestCase;
use stlswm\PiaoZoneAe\StandAlone\Business\InvoiceCreate;
use stlswm\PiaoZoneAe\StandAlone\Client;
use stlswm\PiaoZoneAe\StandAlone\Request\InvoiceCreateReq;
use Trusteeship\Config;

require "../../vendor/autoload.php";
require "Config.php";

/**
 * Class InvoiceCreateReq
 */
class InvoiceCreateTest extends TestCase
{
    /**
     * @throws GuzzleException
     */
    public function testReq()
    {
        $client = Client::newClient(Config::ClientId, Config::ClientSecret, Config::EncryptKey, Config::SalerTaxNo);
        $req = new InvoiceCreateReq();
        $req->czlx = '3';
        $req->sfrz = [
            'client_id'     => $client->clientId,
            'client_secret' => $client->secret,
            'timestamp'     => time(),
        ];
        $req->sjd = [
            'fpqqlsh' => '2023010414231002',
            'hsbz'    => '1',
            'kpzl'=>'',
            'items'   => [
                [
                    'xmmc'    => '',
                    'xmje'    => '',
                    'sl'      => '',
                    'se'      => '',
                    'taxcode' => [
                        'ssflbm' => '',
                        'ssyhzc' => '',
                    ],
                ],
            ]
        ];

        $res = InvoiceCreate::req($client, $req);
        var_dump($res);
        $this->assertEquals('0000', $res->errcode);
    }
}